<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>写文章</title>
	<link rel="short icon" href="/assets/images/favicon.ico" type="image/x-icon">
	<link rel="stylesheet" href="/layout/css/bootstrap.min.css">
	<link rel="stylesheet" href="/layout/css/bootstrap-theme.min.css">
	<script src="/layout/js/jquery.js"></script>
	<script src="/layout/js/bootstrap.min.js"></script>
	<script src="/layout/js/holder.js"></script>
	<script src="/ueditor/ueditor.config.js"></script>
	<script src="/ueditor/ueditor.all.min.js"> </script>
	<script src="/js/plupload.full.min.js"> </script>
</head>
<body>
<nav class="navbar navbar-default">
	<div class="container-fluid" style="">
		<div class="navbar-header col-md-1" style="padding-top: 8px;">
			<img data-src="holder.js/30x30?text=知" alt="">
		</div>
		<div class="col-md-3 text-right" style="padding-top: 6px;">
			<h4><b>写文章</b></h4>
		</div>
		<div class="col-md-8 text-right" style="padding-top: 10px;">
			<button id="btn_upload" class="btn" form="write_add">发布</button>
			<a class="btn" href="/">返回主页</a>
		</div>
	</div>
</nav>
<div class="container">
	<div class="col-md-6 col-md-offset-3">
		<form action="/write" method="post" id="write_add">{{csrf_field()}}
			<div id="img_uploader" class="col-md-12" style="cursor: pointer;">
				<img width="100%" height="200" data-src="holder.js/100px200?text=文章图片" alt="">
				<input type="hidden" name="images" value="">
			</div>
			<div class="col-md-12">
				<input type="text" class="form-control" name="title" placeholder="文章标题" aria-describedby="basic-addon2" form="write_add">
				<select class="form-control" name="column" id="" >
					<option value="0">所属栏目</option>
					@foreach($columns as $k=>$v)
					<option value="{{$v->id}}">{{$v->title}}</option>
					@endforeach
				</select>
				<script id="editor" type="text/plain" style="width:100%;height:500px;"></script>
			</div>
		</form>
	</div>
</div>
<script>
	var ue = UE.getEditor('editor', {
		toolbars: [
			['fullscreen', 'source', 'undo', 'redo', 'bold','indent','insertcode','link','simpleupload',]
		]
	});
	var uploader = new plupload.Uploader({
		browse_button:'img_uploader',
		url:'/api/imgUpload'
	});
	uploader.init();
	uploader.bind('FilesAdded',function(uploader,files){
    	uploader.start();
    });
    uploader.bind('FileUploaded',function(uploader,files, res){
    	console.log(res.response);
    	var img = res.response;
    	$('#img_uploader img').attr('src', img);
    	$('#img_uploader input[name=images]').val(img);
    });
</script>
</body>
</html>